package com.example.kemusan.controller;

import com.example.kemusan.pojo.Result;
import com.example.kemusan.pojo.ResultInfo;
import com.example.kemusan.pojo.StuInfo;
import com.example.kemusan.service.StuInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@Slf4j
@RequestMapping("/stu")
public class StuInfoController {

    @Autowired
    private StuInfoService stuInfoService;

    /**
     * 获得所有考生信息
     * @return
     */
    @PostMapping("/allStu")
    public Result selectAllStu(){
        return stuInfoService.selectAllStu();
    }

    /**
     * 添加考生
     * @param stuInfo
     * @return
     */
    @PostMapping("/insertStu")
    public Result insertStu(@RequestBody StuInfo stuInfo){
        return stuInfoService.insertStu(stuInfo);
    }

    @PostMapping("/resultInfo")
    public Result insertResultInfo(@RequestBody ResultInfo resultInfo){
        return stuInfoService.insertStuScore(resultInfo);
    }

    @PostMapping("/score")
    public Result selectScore(@RequestBody StuInfo stuInfo){
        return stuInfoService.selectScore(stuInfo);
    }
}
